package com.jinzhi.jzweb.utils;

import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

public class CertificateUtil {
    /**
     * 获取字符串拼音的第一个字母
     * @param chinese
     * @return
     */
    public static String toFirstChar(String chinese){
        String pinyinStr = "";
        String pinyinStr1 = "";
        char[] newChar = chinese.toCharArray();  //转为单个字符
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        for (int i = 0; i < newChar.length; i++) {
            if (newChar[i] > 128) {
                try {
                    pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            }else{
                pinyinStr += newChar[i];
            }
        }
        return pinyinStr;
    }

    /**
     * 汉字转为拼音
     * @param chinese
     * @return
     */
    public static String toPinyin(String chinese){
        String pinyinStr = "";
        char[] newChar = chinese.toCharArray();
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        for (int i = 0; i < newChar.length; i++) {
            if (newChar[i] > 128) {
                try {
                    if(i==0){
                        pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0];
                    }else {
                        pinyinStr += " "+PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0];
                    }

                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            }else{
                pinyinStr += newChar[i];
            }
        }
        return pinyinStr;
    }
    private String RecoveryId="1375327865662226434";//产后恢复证书ID
    //组合证书编号
    public static String  comNumber1(String cerNumEnd, String grade) {
        grade=cerNumEnd;
            if (grade.contains("JZ11")) {
                return "产后恢复高级师资";
            } else if (grade.contains("JZ41")) {
                return "产后恢复考评员";
            } else if (grade.contains("JZ31")) {
                return "产后恢复高级考评员";
            }
            else if (grade.contains("JZ51")) {
                return "产后恢复考务技术员";
            }else if(grade.contains("JZ61")) {
                return "产后恢复考务技术员-结业证书";
            }else if (grade.contains("JZ71")) {
                return "产后恢复督导员";
            }else if(grade.contains("JZ81")) {
                cerNumEnd = cerNumEnd + "81";
            }else if(grade.contains("JZ91")) {
                return "产后恢复种子师资";
            }else if(grade.contains("JZ13")) {
                return "产后恢复公益师资";
            }else if(grade.contains("JZ23")) {
                return "产后恢复优秀学员";
            }else if(grade.contains("JZ33")) {
                return "产后恢复优秀培训教师";
            }else if(grade.contains("JZ43")) {
                return "产后恢复优秀考务工作者";
            }else if(grade.contains("JZ53")) {
                return "产后恢复特殊贡献奖";
            }

            if (grade.contains("JZ10")) {
                return "幼儿照护高级师资";
            } else if (grade.contains("JZ40")) {
                return "幼儿照护考评员";
            } else if (grade.contains("JZ30")) {
                return "幼儿照护高级考评员";
            }
            else if (grade.contains("JZ50")) {
                return "幼儿照护考务技术员";
            }else if(grade.contains("JZ60")) {
                return "幼儿照护考务技术员-结业证书";
            }else if (grade.contains("JZ70")) {
                return "幼儿照护督导员";
            }else if(grade.contains("JZ80")) {
                return "幼儿照护督导员-结业证书";
            }else if(grade.contains("JZ90")) {
                return "幼儿照护种子师资证书";
            }else if(grade.contains("JZ12")) {
                return "幼儿照护公益师资证书";
            }else if(grade.contains("JZ55")) {
                return "幼儿照护综合公益师资证书";
            }else if(grade.contains("JZ22")) {
                return "幼儿照护优秀学员";
            }else if(grade.contains("JZ32")) {
                return "幼儿照护优秀培训教师";
            }else if(grade.contains("JZ42")) {
                return "幼儿照护优秀考务工作者";
            }else if(grade.contains("JZ52")) {
                return "幼儿照护特殊贡献奖";
            }else if(grade.contains("JZ20")) {
                return "幼儿照护/产后恢复师资";
            }else if(grade.contains("JZ21")) {
                return "素质提高计划(幼儿照护1+X中级证书)";
            }

            //     <option value="21">素质提高计划(幼儿照护1+X中级证书)</option>
            else {
                return "职业技能证书";
            }


    }

}
